package com.rg.servlet;

import com.rg.model.GoodsModel;
import com.rg.service.GoodsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/GoodsDetailServlet")
public class GoodsDetailServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int goodsId= Integer.parseInt(request.getParameter("goodsId"));
        GoodsService goodsService=new GoodsService();
        GoodsModel goods=goodsService.selectOneGoodsBygoodsId(goodsId);
// System.out.println(goods);
        request.setAttribute("goods",goods);
        request.getRequestDispatcher("goodsDetail.jsp").forward(request,response);
    }


}
